# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Spider.007 <archlinux AT spider007 DOT net>

pkgname=python-stem
_pypiname=${pkgname#*-}
pkgver=1.8.1
pkgrel=2
pkgdesc='Python controller library for Tor'
url='https://stem.torproject.org/'
arch=('any')
license=('LGPL3')
depends=('python' 'python-cryptography' 'python-pynacl' 'procps-ng')
checkdepends=('tor')
optdepends=('tor: tor-server to talk to')
replaces=('stem')
provides=('stem')
source=(https://files.pythonhosted.org/packages/source/${_pypiname::1}/${_pypiname}/${_pypiname}-${pkgver}.tar.gz{,.asc}
        python3-11.patch)
sha256sums=('81d43a7c668ba9d7bc1103b2e7a911e9d148294b373d27a59ae8da79ef7a3e2f'
            'SKIP'
            '8d5b906ec0a007946a943516e0bb997e0fcf10a6544bca893ce06600c6114d4c')
validpgpkeys=('68278CC5DD2D1E85C4E45AD90445B7AB9ABBEEC6') # Damian Johnson (www.atagar.com) <atagar1@gmail.com>

prepare() {
  cd ${_pypiname}-${pkgver}
  # https://github.com/torproject/stem/issues/56
  sed -i '/MOCK_VERSION/d' run_tests.py
  # remove flaky integration tests
  sed -i test/settings.cfg \
    -e '/|test.integ.client.connection.TestConnection/d' \
    -e '/|test.integ.process.TestProcess/d' \
    -e '/|test.integ.installation.TestInstallation/d' \
    -e '/|test.integ.control.controller.TestController/d'
  rm test/integ/{client/connection,{installation,process},control/controller}.py
  patch -Np1 -i ../python3-11.patch
}

build() {
  cd ${_pypiname}-${pkgver}
  python setup.py build
}

check() {
  cd ${_pypiname}-${pkgver}
  ./run_tests.py --all
}

package() {
  cd ${_pypiname}-${pkgver}
  python setup.py install --optimize=1 --root="${pkgdir}" --skip-build
}

# vim: ts=2 sw=2 et:
